package com.zy.dp.singleton.example5;

import java.util.HashMap;
import java.util.Map;

public class Singleton
{

	private final static String DEFAULT_KEY = "One";
	private static Map<String, Singleton> map = new HashMap<String, Singleton>();

	private Singleton()
	{

	}

	public static Singleton getInstance()
	{

		Singleton instance = map.get(DEFAULT_KEY);
		if (instance == null)
		{
			instance = new Singleton();

			map.put(DEFAULT_KEY, instance);
		}

		return instance;

	}

	public static void main(String[] args)
	{
		for (int i = 0; i < 5; i++)

		{
			System.out.println(Singleton.getInstance());

		}
	}

}
